options ls = 100 ps = 80 probsig = 2;

data fuzzy1;
   informat code $20.;informat bcode $20.;
   infile 'c:/My Documents/data/scat.1/RToneIATA.dat' delimiter='09'x;
   input date    time  $  build  sub   code    $   block   trial lat     resp  $  corr  trialitm    bcode $;
data fuzzy2;
   informat code $20.;informat bcode $20.;
   infile 'c:/My Documents/data/scat.1/RToneIATB.dat' delimiter='09'x;
   input date    time  $  build  sub   code    $   block   trial lat     resp  $  corr  trialitm    bcode $;
data fuzzy4;
   informat code $20.;informat bcode $20.;
   infile 'c:/My Documents/data/scat.1/RToneIATE.dat' delimiter='09'x;
   input date    time  $  build  sub   code    $   block   trial lat     resp  $  corr  trialitm    bcode $;
data fuzzy5;
   informat code $20.;informat bcode $20.;
   infile 'c:/My Documents/data/scat.1/RToneIATF.dat' delimiter='09'x;
   input date    time  $  build  sub   code    $   block   trial lat     resp  $  corr  trialitm    bcode $;
data fuzzy6;
   informat code $20.;informat bcode $20.;
   infile 'c:/My Documents/data/scat.1/RToneIATE2.dat' delimiter='09'x;
   input date    time  $  build  sub   code    $   block   trial lat     resp  $  corr  trialitm    bcode $;
data fuzzy7;
   informat code $20.;informat bcode $20.;
   infile 'c:/My Documents/data/scat.1/RToneIATB2.dat' delimiter='09'x;
   input date    time  $  build  sub   code    $   block   trial lat     resp  $  corr  trialitm    bcode $;
data temp; set fuzzy1 fuzzy2 fuzzy4 fuzzy5 fuzzy6 fuzzy7;

if block in (1,2) then delete;if trial < 19 then delete;
if code in ('bugs_false1000', 'fruit_false1000', 'good_false1000', 'bad_false1000',
             'bugs_false833', 'fruit_false833', 'good_false833', 'bad_false833',
             'bugs_false666', 'fruit_false666', 'good_false666', 'bad_false666',
             'bugs_false500', 'fruit_false500', 'good_false500', 'bad_false500')
then item = 0;else item = 1;

if corr = 0 and item = 0 then response = 'corrrej';
if corr = 0 and item = 1 then response = 'miss';
if corr = 1 and item = 0 then response = 'falsalrm';
if corr = 1 and item = 1 then response = 'hit';
if response in ('falsalrm', 'corrrej') then delete;
speed = lat;

/*proc means n mean std stderr; class bcode; var lat; run;*/

proc sort; by sub bcode; run;
proc means noprint;
  by sub bcode; var speed; output out=means  mean=speed; run;
proc transpose data=means prefix=speed name=name out=spdmeans;by sub;run;
proc sort; by name; run;
data prac;  set spdmeans; if name ^= 'speed' then delete;

data explicit;
  informat major $25.;informat Afavrte $15.; informat ethnicit $15.;
  infile 'c:/My Documents/data/scAT.1/AAT.explicit.1.dat.txt' delimiter='09'x;
  input #1 sub Afruit Abugs Amath Apsych Aengr Aarts Abiology Areading Ascience Aenglish
            Aphysics Aphil AR1 $ AR2 $ AR3 $ AR4 $ AR5 $ AR6 $ AR7 $ AR8 $ AR9 $ AR10 $
            Afavrte $ BSRI1 BSRI2 BSRI3 BSRI4 BSRI5 BSRI6 BSRI7 BSRI8 BSRI9 BSRI10
            BSRI11 BSRI12 BSRI13 BSRI14 BSRI15 BSRI16 BSRI17 BSRI18 BSRI19 BSRI20
            BSRI21 BSRI22 BSRI23 BSRI24 BSRI25 BSRI26 BSRI27 BSRI28 BSRI29 BSRI30
            BSRI31 BSRI32 BSRI33 BSRI34
        #2  BSRI35 BSRI36 BSRI37 BSRI38 BSRI39 BSRI40
            BSRI41 BSRI42 BSRI43 BSRI44 BSRI45 BSRI46 BSRI47 BSRI48 BSRI49 BSRI50
            BSRI51 BSRI52 BSRI53 BSRI54 BSRI55 BSRI56 BSRI57 BSRI58 BSRI59 BSRI60
            GID1 GID2 GID3 GID3 GID5 GID6 GID7 GID8 GID9 GID10 GID11 GID12 GID13 GID14
            year major $ age sex $ ethnicit $ bornUS UShwlng Engfirst Enghwlng
            glasses handed $ sleep alert computer hrsoncmp comfort Dgender Dage Drace Dses;

data IAT;
  infile 'c:/My Documents/data/scAT.1/IATdata.txt' delimiter='09'x;
  input sub fruitgd fruitbd fruitbug mathgd mathbd mathread;

proc sort data=explicit; by sub; run;
data prac; merge prac (in=frog) explicit; by sub; if frog; run;
proc sort; by sub;
data prac; merge prac (in=frog) IAT; by sub;if frog; run;
proc sort; by sex sub;run;

data prac;
  set prac;
  drop BSRI1-BSRI60; drop GID1 - GID14; Afrtbug = Afruit - Abugs;
  bgbd1000 = speed1; bgbd500 = speed2; bgbd666 = speed3; bgbd833 = speed4;
  bggd1000 = speed5; bggd500 = speed6; bggd666 = speed7; bggd833 = speed8;
  ftbd1000 = speed9; ftbd500 = speed10; ftbd666 = speed11; ftbd833 = speed12;
  ftgd1000 = speed13; ftgd500 = speed14; ftgd666 = speed15; ftgd833 = speed16;
  bug1000 = bgbd1000 - bggd1000; bug833 = bgbd833 - bggd833;
  bug666 = bgbd666 - bggd666; bug500 = bgbd500 - bggd500;
  frut1000 = ftbd1000 - ftgd1000; frut833 = ftbd833 - ftgd833;
  frut666 = ftbd666 - ftgd666; frut500 = ftbd500 - ftgd500;
  fruit = mean(frut1000, frut833, frut666, frut500);
  bugs = mean(bug1000, bug833, bug666, bug500);
  ftbd = mean(ftbd1000, ftbd833, ftbd666, ftbd500);
  ftgd = mean(ftgd1000, ftgd833, ftgd666, ftgd500);
  bgbd = mean(bgbd1000, bgbd833, bgbd666, bgbd500);
  bggd = mean(bggd1000, bggd833, bggd666, bggd500);

proc means; var bgbd bggd ftbd ftgd;run;
proc glm; model bgbd bggd = ; repeated bug 2; run;
proc glm; model ftbd ftgd = ; repeated fruit 2; run;

/*proc means;
  var  bgbd500 bgbd666 bgbd833 bgbd1000 bggd500 bggd666 bggd833 bggd1000
       ftbd500 ftbd666 ftbd833 ftbd1000 ftgd500 ftgd666 ftgd833 ftgd1000;run;
proc means;
  var  bug500 bug666 bug833 bug1000 frut500 frut666 frut833 frut1000;run;
proc corr;
  var bug500 bug666 bug833 bug1000 frut500 frut666 frut833 frut1000;run;
proc corr;
  var bugs fruit;
  with bug500 bug666 bug833 bug1000 bugs frut500 frut666 frut833 frut1000; run;*/

/*proc corr;
  var Afrtbug Afruit Abugs fruitbug fruitgd fruitbd;
  with bug500 bug666 bug833 bug1000 bugs frut500 frut666 frut833 frut1000 fruit; run; 

proc glm; model bgbd500 bggd500 = ; repeated bug 2; run;
proc glm; model bgbd666 bggd666 = ; repeated bug 2; run;
proc glm; model bgbd833 bggd833 = ; repeated bug 2; run;
proc glm; model bgbd1000 bggd1000 = ; repeated bug 2; run;
proc glm; model ftbd500 ftgd500 = ; repeated fruit 2; run;
proc glm; model ftbd666 ftgd666 = ; repeated fruit 2; run;
proc glm; model ftbd833 ftgd833 = ; repeated fruit 2; run;
proc glm; model ftbd1000 ftgd1000 = ; repeated fruit 2; run;
proc glm; model bgbd833 bggd833 ftbd833 ftgd833 = ; repeated object 2, att 2; run;*/
